﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace SPN.WebParts.Confirmation
{
    [ToolboxItemAttribute(false)]
    public class Confirmation : WebPart
    {
        #region Properties
        private string _Settings_WebUrl = "";
        [Personalizable(true)]
        [WebBrowsable(true)]
        [Category("SPN - Settings")]
        [DisplayName("Web url")]
        public string Settings_WebUrl
        {
            get { return _Settings_WebUrl; }
            set { _Settings_WebUrl = value; }
        }

        private string _Label_SubscribeMessage = "You have been successfully subscribed";
        [Personalizable(true)]
        [WebBrowsable(true)]
        [Category("SPN - Labels")]
        [DisplayName("Subscribed message message")]
        public string Label_SubscribeMessage
        {
            get { return _Label_SubscribeMessage; }
            set { _Label_SubscribeMessage = value; }
        }

        private string _Label_AlreadySubscribeMessage = "Entered E-mail is already subscribed";
        [Personalizable(true)]
        [WebBrowsable(true)]
        [Category("SPN - Labels")]
        [DisplayName("Already subscribed message message")]
        public string Label_AlreadySubscribeMessage
        {
            get { return _Label_AlreadySubscribeMessage; }
            set { _Label_AlreadySubscribeMessage = value; }
        }

        private string _Label_UnSubscribedMessage = "You have been successfully unsubscribed";
        [Personalizable(true)]
        [WebBrowsable(true)]
        [Category("SPN - Labels")]
        [DisplayName("UnSubscribed message message")]
        public string Label_UnSubscribedMessage
        {
            get { return _Label_UnSubscribedMessage; }
            set { _Label_UnSubscribedMessage = value; }
        }

        private string _Label_CodeNotValid = "Code is not valid.";
        [Personalizable(true)]
        [WebBrowsable(true)]
        [Category("SPN - Labels")]
        [DisplayName("Code not valid")]
        public string Label_CodeNotValid
        {
            get { return _Label_CodeNotValid; }
            set { _Label_CodeNotValid = value; }
        }

        private string _Label_EmailNotValid = "Entered E-mail is not valid.";
        [Personalizable(true)]
        [WebBrowsable(true)]
        [Category("SPN - Labels")]
        [DisplayName("Email Not Valid")]
        public string Label_EmailNotValid
        {
            get { return _Label_EmailNotValid; }
            set { _Label_EmailNotValid = value; }
        }
        #endregion

        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/SPN.WebParts/Confirmation/ConfirmationUserControl.ascx";

        protected override void CreateChildControls()
        {
            ConfirmationUserControl _uc = (ConfirmationUserControl)Page.LoadControl(_ascxPath);
            _uc._Settings_WebUrl = _Settings_WebUrl;
            _uc._Label_AlreadySubscribeMessage = _Label_AlreadySubscribeMessage;
            _uc._Label_CodeNotValid = _Label_CodeNotValid;
            _uc._Label_EmailNotValid = _Label_EmailNotValid;
            _uc._Label_SubscribeMessage = _Label_SubscribeMessage;
            _uc._Label_UnSubscribeMessage = _Label_UnSubscribedMessage;
            Controls.Add(_uc);
        }
    }
}
